package Entity;

import java.util.Arrays;
import java.util.Objects;

public class Question {
    private int num;
    private String content;
    private char type;
    private String[] options = new String[3];
    private boolean[] answer;

    public Question() {}

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Question)) return false;
        Question question = (Question) o;
        return getNum() == question.getNum() && getType() == question.getType() && Objects.equals(getContent(), question.getContent()) && Arrays.equals(getOptions(), question.getOptions()) && Arrays.equals(getAnswer(), question.getAnswer());
    }

    @Override
    public int hashCode() {
        int result = Objects.hash(getNum(), getContent(), getType());
        result = 31 * result + Arrays.hashCode(getOptions());
        result = 31 * result + Arrays.hashCode(getAnswer());
        return result;
    }

    public Question(String content, char type, String[] options, boolean[] answer) {
        this.content = content;
        this.type = type;
        this.options = options;
        this.answer = answer;
    }

    public int getNum() {
        return num;
    }
    public void setNum(int num) {
        this.num = num;
    }
    public String getContent() {
        return content !=null ? content : new String();
    }
    public void setContent(String content) {
        this.content = content;
    }
    public char getType() {
        return type;
    }
    public void setType(char type) {
        this.type = type;
    }
    public String[] getOptions() {
        return options;
    }
    public void setOptions(String[] options) {
        this.options = options;
    }
    public boolean[] getAnswer() {
        return answer;
    }
    public void setAnswer(boolean[] answer) {
        this.answer = answer;
    }
}
